package com.ymatou.iapi.userservice.testcase;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

import com.ymatou.iapi.userservice.parameter.QueryBuyerLevelRequestDtoBean;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.service.QueryBuyerLevelRequestDtoCall;
/**
*批量查询用户
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryBuyerLevelRequestDto{
	private static QueryBuyerLevelRequestDtoBean QueryBuyerLevelRequestDtoBean;
	private static QueryBuyerLevelRequestDtoCall QueryBuyerLevelRequestDtoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量查询用户");
	}

	@Before
	public void caseUp() {
		QueryBuyerLevelRequestDtoBean=new QueryBuyerLevelRequestDtoBean();
		QueryBuyerLevelRequestDtoCall=new QueryBuyerLevelRequestDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(QueryBuyerLevelRequestDtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_001() {
		Logger.start(true,"查询用户等级1");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			QueryBuyerLevelRequestDtoBean.setIn("1");
			QueryBuyerLevelRequestDtoBean.setIsGetNextLevel("0");
			QueryBuyerLevelRequestDtoBean.setQueryKey(uid.toString());
			QueryBuyerLevelRequestDtoBean.setQueryType("1");
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("200", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("true", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
			JsonObject js = QueryBuyerLevelRequestDtoCall.getJsonObject().get("Result").getAsJsonArray().get(0).getAsJsonObject();
			Logger.verifyEquals(1,js.get("CurrentLevel").getAsInt(),"验证等级");
			Logger.verifyEquals("普通会员",js.get("LevelDescription").getAsString(),"验证等级描述");
			Logger.verifyEquals(2,js.get("NextLevel").getAsInt(),"验证下级等级");
			Logger.verifyEquals("白银会员",js.get("NextLevelDescription").getAsString(),"验证下级等级描述");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_002() {
		Logger.start(true,"查询用户等级2");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.ExpChange(uid, 2);
			QueryBuyerLevelRequestDtoBean.setIn("1");
			QueryBuyerLevelRequestDtoBean.setIsGetNextLevel("0");
			QueryBuyerLevelRequestDtoBean.setQueryKey(uid.toString());
			QueryBuyerLevelRequestDtoBean.setQueryType("1");
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("200", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("true", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
			JsonObject js = QueryBuyerLevelRequestDtoCall.getJsonObject().get("Result").getAsJsonArray().get(0).getAsJsonObject();
			Logger.verifyEquals(2,js.get("CurrentLevel").getAsInt(),"验证等级");
			Logger.verifyEquals("白银会员",js.get("LevelDescription").getAsString(),"验证等级描述");
			Logger.verifyEquals(3,js.get("NextLevel").getAsInt(),"验证下级等级");
			Logger.verifyEquals("黄金会员",js.get("NextLevelDescription").getAsString(),"验证下级等级描述");
			JUserCallService.ExpChange(uid, 1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_003() {
		Logger.start(true,"查询用户等级3");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.ExpChange(uid, 3);
			QueryBuyerLevelRequestDtoBean.setIn("1");
			QueryBuyerLevelRequestDtoBean.setIsGetNextLevel("0");
			QueryBuyerLevelRequestDtoBean.setQueryKey(uid.toString());
			QueryBuyerLevelRequestDtoBean.setQueryType("1");
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("200", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("true", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
			JsonObject js = QueryBuyerLevelRequestDtoCall.getJsonObject().get("Result").getAsJsonArray().get(0).getAsJsonObject();
			Logger.verifyEquals(3,js.get("CurrentLevel").getAsInt(),"验证等级");
			Logger.verifyEquals("黄金会员",js.get("LevelDescription").getAsString(),"验证等级描述");
			Logger.verifyEquals(4,js.get("NextLevel").getAsInt(),"验证下级等级");
			Logger.verifyEquals("铂金会员",js.get("NextLevelDescription").getAsString(),"验证下级等级描述");
			JUserCallService.ExpChange(uid, 1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_004() {
		Logger.start(true,"查询用户等级4");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.ExpChange(uid, 4);
			QueryBuyerLevelRequestDtoBean.setIn("1");
			QueryBuyerLevelRequestDtoBean.setIsGetNextLevel("0");
			QueryBuyerLevelRequestDtoBean.setQueryKey(uid.toString());
			QueryBuyerLevelRequestDtoBean.setQueryType("1");
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("200", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("true", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
			JsonObject js = QueryBuyerLevelRequestDtoCall.getJsonObject().get("Result").getAsJsonArray().get(0).getAsJsonObject();
			Logger.verifyEquals(4,js.get("CurrentLevel").getAsInt(),"验证等级");
			Logger.verifyEquals("铂金会员",js.get("LevelDescription").getAsString(),"验证等级描述");
			Logger.verifyEquals(5,js.get("NextLevel").getAsInt(),"验证下级等级");
			Logger.verifyEquals("钻石会员",js.get("NextLevelDescription").getAsString(),"验证下级等级描述");
			JUserCallService.ExpChange(uid, 1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_005() {
		Logger.start(true,"查询用户等级5");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.ExpChange(uid, 5);
			QueryBuyerLevelRequestDtoBean.setIn("1");
			QueryBuyerLevelRequestDtoBean.setIsGetNextLevel("0");
			QueryBuyerLevelRequestDtoBean.setQueryKey(uid.toString());
			QueryBuyerLevelRequestDtoBean.setQueryType("1");
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("200", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("true", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
			JsonObject js = QueryBuyerLevelRequestDtoCall.getJsonObject().get("Result").getAsJsonArray().get(0).getAsJsonObject();
			Logger.verifyEquals(5,js.get("CurrentLevel").getAsInt(),"验证等级");
			Logger.verifyEquals("钻石会员",js.get("LevelDescription").getAsString(),"验证等级描述");
			Logger.verifyEquals(6,js.get("NextLevel").getAsInt(),"验证下级等级");
			Logger.verifyEquals("黑卡会员",js.get("NextLevelDescription").getAsString(),"验证下级等级描述");
			JUserCallService.ExpChange(uid, 1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_006() {
		Logger.start(true,"查询用户等级6");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.ExpChange(uid, 6);
			QueryBuyerLevelRequestDtoBean.setIn("1");
			QueryBuyerLevelRequestDtoBean.setIsGetNextLevel("0");
			QueryBuyerLevelRequestDtoBean.setQueryKey(uid.toString());
			QueryBuyerLevelRequestDtoBean.setQueryType("1");
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("200", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("true", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
			JsonObject js = QueryBuyerLevelRequestDtoCall.getJsonObject().get("Result").getAsJsonArray().get(0).getAsJsonObject();
			Logger.verifyEquals(6,js.get("CurrentLevel").getAsInt(),"验证等级");
			Logger.verifyEquals("黑卡会员",js.get("LevelDescription").getAsString(),"验证等级描述");
			Logger.verifyEquals(6,js.get("NextLevel").getAsInt(),"验证下级等级");
			Logger.verifyEquals("黑卡会员",js.get("NextLevelDescription").getAsString(),"验证下级等级描述");
			JUserCallService.ExpChange(uid, 1);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryBuyerLevelRequestDto_007() {
		Logger.start(true,"不输入参数");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.ExpChange(uid, 6);
			QueryBuyerLevelRequestDtoCall.setData(QueryBuyerLevelRequestDtoBean);
			QueryBuyerLevelRequestDtoCall.callService();			
			Logger.verifyEquals("100", QueryBuyerLevelRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyEquals("false", QueryBuyerLevelRequestDtoCall.getString("Success"), "验证Success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}